#!/bin/bash

poweroff()
{
    echo $$ > /tmp/poweroff.pid
    wall "5分钟后要关机了, 请做好准备..."
    sleep 300
    init 0
}

cancel()
{
    kill -9 $(cat /tmp/poweroff.pid)
}

[ x$1 = xc ] && cancel || poweroff

